//
//  SearchGoodsTableViewCell.m
//  GLGW_Shoping
//
//  Created by yang on 2018/11/8.
//  Copyright © 2018年 yang. All rights reserved.
//

#import "SearchGoodsTableViewCell.h"

@implementation SearchGoodsTableViewCell{
    GLGWImageView * goodsImageView;
    GLGWLabel * goodsTitleLabel;
    GLGWLabel * specificationsLabel;
    GLGWLabel * warehouseLabel;
    GLGWLabel * storeNameLabel;
    GLGWLabel * moneyLabel;
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        GLGWView * bankgroundView = [[GLGWView alloc] initWithFrame:CGRectMake(kWidthProportion_In_iPhoneTriploid(15), kHeightProportion_In_iPhoneTriploid(10), KScreenWidth-kWidthProportion_In_iPhoneTriploid(30), kHeightProportion_In_iPhoneTriploid(112)) inSuperView:self];
        [bankgroundView setViewShadowWidth:3.0 theCornerRadius:3.0];
        bankgroundView.backgroundColor = [UIColor whiteColor];
        //
        goodsImageView = [[GLGWImageView alloc] initWithFrame:CGRectMake(kWidthProportion_In_iPhoneTriploid(16), kHeightProportion_In_iPhoneTriploid(15), kWidthProportion_In_iPhoneTriploid(82), kHeightProportion_In_iPhoneTriploid(82)) inSuperView:bankgroundView];
        goodsImageView.backgroundColor = kRandomColor;
        //标题
        goodsTitleLabel = [[GLGWLabel alloc] initWithFrame:CGRectMake(kX_With_View(goodsImageView, 19), kHeightProportion_In_iPhoneTriploid(20), bankgroundView.width - kX_With_View(goodsImageView, 19) - kWidthProportion_In_iPhoneTriploid(16), kHeightProportion_In_iPhoneTriploid(22)) theFont:SYSTEMFONT(16) theColor:[UIColor colorWithHexString:@"#333333"] inSuperView:bankgroundView];
//        goodsTitleLabel.backgroundColor = kRandomColor;
        //    goodsTitleLabel.text = @"三级螺纹钢 HRB400E 河钢";
        //仓库
        warehouseLabel = [[GLGWLabel alloc] initWithFont:SYSTEMFONT(12) theColor:[UIColor colorWithHexString:@"#999999"] inSuperView:bankgroundView];
        [warehouseLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(bankgroundView.mas_right).offset(-kWidthProportion_In_iPhoneTriploid(15));
            make.top.equalTo(self->goodsTitleLabel.mas_bottom).offset(kHeightProportion_In_iPhoneTriploid(8));
            make.height.equalTo(@(kHeightProportion_In_iPhoneTriploid(17)));
        }];
//        warehouseLabel.backgroundColor = kRandomColor;
//        warehouseLabel.text = @"北京京南国储库";
        //规格
        specificationsLabel = [[GLGWLabel alloc] initWithFrame:CGRectMake(goodsTitleLabel.x, kY_With_View(goodsTitleLabel, 5), kWidthProportion_In_iPhoneTriploid(50), kHeightProportion_In_iPhoneTriploid(22)) theFont:SYSTEMFONT(16) theColor:[UIColor colorWithHexString:@"#666666"] inSuperView:bankgroundView];
        specificationsLabel = [[GLGWLabel alloc] initWithFont:SYSTEMFONT(16) theColor:[UIColor colorWithHexString:@"#666666"] inSuperView:bankgroundView];
        [specificationsLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self->goodsImageView.mas_right).offset(kWidthProportion_In_iPhoneTriploid(15));
            make.top.equalTo(self->goodsTitleLabel.mas_bottom).offset(kHeightProportion_In_iPhoneTriploid(5));
            make.height.equalTo(@(kHeightProportion_In_iPhoneTriploid(22)));
            make.right.equalTo(self->warehouseLabel.mas_left).offset(-kWidthProportion_In_iPhoneTriploid(10));
        }];
//        specificationsLabel.backgroundColor = kRandomColor;
//        specificationsLabel.text = @"φ6*12";
        //
        moneyLabel = [[GLGWLabel alloc] initWithFont:SYSTEMFONT(14) theColor:[UIColor colorWithHexString:@"#EC5353"] inSuperView:bankgroundView];
        moneyLabel.textAlignment = NSTextAlignmentRight;
        [moneyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.equalTo(bankgroundView.mas_bottom).offset(-kHeightProportion_In_iPhoneTriploid(20));
            make.right.equalTo(bankgroundView.mas_right).offset(-kWidthProportion_In_iPhoneTriploid(15));
            make.height.equalTo(@(kHeightProportion_In_iPhoneTriploid(20)));
        }];
        //
        GLGWButton * inStoreBut = [[GLGWButton alloc] initWithTitle:@"进店" titleLableFont:SYSTEMFONT(12) titleLableColor:kColor_Rule_Yellow inSuperView:bankgroundView];
        inStoreBut.image_Name = @"icon_jindian";
        [inStoreBut setImagePositionWithType:SSImagePositionTypeRight spacing:0];
        [inStoreBut mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self->moneyLabel.mas_left).offset(-kWidthProportion_In_iPhoneTriploid(10));
            make.top.equalTo(self->specificationsLabel.mas_bottom).offset(kHeightProportion_In_iPhoneTriploid(5));
            make.height.equalTo(@(kHeightProportion_In_iPhoneTriploid(17)));
        }];
        [inStoreBut addTarget:self action:@selector(chickStore) forControlEvents:UIControlEventTouchUpInside];
        //
        storeNameLabel = [[GLGWLabel alloc] initWithFont:SYSTEMFONT(12) theColor:[UIColor colorWithHexString:@"#999999"] inSuperView:bankgroundView];
        [storeNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self->specificationsLabel);
            make.top.height.equalTo(inStoreBut);
            make.right.equalTo(inStoreBut.mas_left).offset(-kWidthProportion_In_iPhoneTriploid(10));
        }];
//        storeNameLabel.text = @"小张店铺";
        
    }
    return self;
}

-(void)setCatInforModel:(HomecategoryproductinfosModel_CategoryProductInfos *)catInforModel{
    _catInforModel = catInforModel;
    [goodsImageView sd_setImageWithURL:[NSURL URLWithString:_catInforModel.imageUrl] placeholderImage:[UIImage imageNamed:@"kk"]];
    goodsTitleLabel.text = [NSString stringWithFormat:@"%@ %@ %@",koString(_catInforModel.productsSeller.productName),koString(_catInforModel.productsSeller.productMaterial),koString(_catInforModel.productsSeller.factoryName)];
    //
    specificationsLabel.text = _catInforModel.productsSeller.specifications;
    warehouseLabel.text = _catInforModel.productsSeller.storehouseName;
    storeNameLabel.text = _catInforModel.productsSeller.storehouseName;
    moneyLabel.text = [NSString stringWithFormat:@"¥%.2f/吨",_catInforModel.price];
}

-(void)chickStore{
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
